<!DOCTYPE html>
<html>
<head>
{include file="common/head"}
<style type="text/css">

</style>
<script type="text/javascript">
var wdinfo = {
  id: '{$question.id}'
  ,tags: '{$question.tags}'
  ,title: '{$question.title}'
  ,createTime: '{$question.create_time}'
};
var CF = {
	URL: {
		UP_ASK: '{:url('wendasns/common/upload',['type'=>'question'])->domain(true)}',
		UP_ANS: '{:url('wendasns/common/upload',['type'=>'answer'])->domain(true)}',
		USER_CARD: '{:url('wendasns/api/userinfo')->domain(true)}',
		COMMENT_LIST: '{:url('wendasns/answer/comment')->domain(true)}',
		COMMENT: '{:url('wendasns/comment/post')->domain(true)}',
	}
};
</script>
</head>

<body>
{include file="common/header"}
<div class="layui-container" style="margin-top: 80px;">
  <div class="layui-row layui-col-space15">
   <div class="layui-col-md12">
    <div class="layui-card">
       <div class="layui-row">
        <div class="layui-col-md8">
        	{if $question.status eq 'check'}<div class="layui-card-header" style="color: #FFB800;">问题审核中</div>{/if}
          <div class="layui-card-body">
            {if $question.tags}<p><i class="layui-icon layui-icon-note" style="font-size: 16px;"></i> {volist name=":explode(',',$question.tags)" id="item"}<a href="{:url('wendasns/topic/show',['tags'=>$item])}" class="tag">{$item}</a> {/volist} </p>{/if}
            <div class="ask-title" style="margin-bottom: 10px;margin-top: 20px;line-height: 40px;color: #333;"><h1>{$question.title}</h1></div>
            <div class="ask-userinfo" style="margin-bottom: 20px;">
              {if $question.user_id neq $loginUser.uid}
              {if $question.anonymous}<span style="margin-right: 10px;"><i class="layui-icon layui-icon-username"></i> 匿名提问</span>{else}<a href="{:url('wendasns/home/index',['id'=>$question.user_id],false)}" class="userinfo-show portrait-xs" style="margin-right: 10px;" data-uid="{$question.user_id}">{:portrait($question.user_id)}{$question.users.username}</a>{/if}
              {/if}
              <i class="layui-icon layui-icon-date"></i> <span>{:range_time($question.create_time)}</span>
            </div>
            <div id="askContent" class="ask-content" style="color: #333;">{$question.content|raw}</div>
            <div class="ask-handle" style="margin-top: 20px;">
              {if $question.user_id eq $loginUser.uid}
              <a href="{:url('wendasns/question/edit')}" onclick="wds.call(this,'editor','ask');return false;" style="margin-right: 10px;"><i class="layui-icon layui-icon-edit"></i> 补充问题</a>
              <a href="{:url('wendasns/question/remove')}" style="margin-right: 10px;" class="J_req" data-json='{"id":"{$question.id}"}' title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i> 删除</a>
              {else}
              <a href="{:url('wendasns/answer/send')}" class="layui-btn layui-btn-sm layui-btn-primary" onclick="wds.call(this,'editor','answer');return false;" style="margin-right: 10px;" data-type="0"><i class="layui-icon layui-icon-edit"></i>写回答</a>
              {if $question.iscollect}
              <a href="javascript:;" style="margin-right: 10px;"><i class="layui-icon layui-icon-star-fill"></i> 已收藏</a>
              {else}
              <a href="{:url('wendasns/question/collect')}" style="margin-right: 10px;" class="J_req" data-json='{"id":"{$question.id}"}' data-click="collect"><i class="layui-icon layui-icon-star"></i> 收藏</a>
              {/if}
              <a href="{:url('wendasns/api/report')}" style="margin-right: 10px;" class="J_dialog" data-json='{"id":"{$question.id}","type":"question"}' title="举报"><i class="layui-icon layui-icon-tips"></i> 举报</a>
              {/if}
              {if miniapp() neq true}<a href="#share" class="J_req" data-click="share" style="margin-right: 10px;"><i class="layui-icon layui-icon-share"></i> 分享</a>{/if}
              {if admin_check('thread.top')}
              	{if $question.top}<a href="{:url('wendasns/common/top',['type'=>'question'])}" style="margin-right: 10px;color: #01AAED;" class="J_req" data-json='{"id":"{$question.id}"}' data-click="top"><i class="layui-icon layui-icon-top"></i> 取消置顶</a>{else}<a href="{:url('wendasns/common/top',['type'=>'question'])}" style="margin-right: 10px;color: #01AAED;" class="J_req" data-json='{"id":"{$question.id}"}' data-click="top"><i class="layui-icon layui-icon-top"></i> 置顶</a>{/if}
              {/if}
              {if admin_check('thread.recommend')}
              	{if $question.recommend}<a href="{:url('wendasns/common/recommend',['type'=>'question'])}" style="margin-right: 10px;color: #FF5722;" class="J_req" data-json='{"id":"{$question.id}"}' data-click="recommend"><i class="layui-icon layui-icon-fire"></i> 取消推荐</a>{else}<a href="{:url('wendasns/common/recommend',['type'=>'question'])}" style="margin-right: 10px;color: #FF5722;" class="J_req" data-json='{"id":"{$question.id}"}' data-click="recommend"><i class="layui-icon layui-icon-fire"></i> 推荐</a>{/if}
              {/if}
              {if $question.status eq 'check' && admin_check('thread.check')}
              	<a href="{:url('wendasns/common/check',['type'=>'question'])}" style="margin-right: 10px;" class="J_req" data-json='{"id":"{$question.id}"}'><i class="layui-icon layui-icon-auz"></i> 审核通过</a>
              {/if}
              {if $question.client}<span style="color: #009688;">来自：{$question.client}客户端</span>{/if}
            </div>
          </div>
        </div>
        
        <div class="layui-col-md4">
          <div class="layui-card-body">
            <br>
            <div class="layui-row" style="text-align: center;"><div class="layui-col-md6 layui-col-sm6 layui-col-xs6"><p>收藏量</p><mdall>{$question.collect}</mdall></div><div class="layui-col-md6 layui-col-sm6 layui-col-xs6"><p>浏览量</p><mdall>{$question.visits}</mdall></div></div>
          </div>
        </div>
        
       </div>
    </div>
   </div>
  </div>
  <!---->
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8">
      <!--我来回答-->
      <div id="form-card" class="layui-card" style="display: none;"></div>
      
      <!--最佳答案-->
      {if $question.adopt}
      <div class="layui-card">
        <div class="layui-card-header" style="color: #009688;"><span><i class="layui-icon layui-icon-vercode" style="position: relative;right: 0;top: 0;"></i> 本回复由提问者采纳</span></div>
        <div class="layui-card-body">
          <div class="wenda-answer-userinfo">
            {if $question.adopt.user_id eq $loginUser.uid}
            我的回复
            {else}
            <div class="portrait-de" style="float: left;">{:portrait($question.adopt.user_id)}</div>
            <div style="float: left;"><p><a href="{:url('wendasns/home/index',['id'=>$question.adopt.user_id],false)}" class="userinfo-show" style="margin-right: 5px;font-weight: bold;" data-uid="{$question.adopt.user_id}" target="_blank">{$question.adopt.users.username}</a></p><p style="color: #9eacb6;font-size: 12px;">{$question.adopt.users.members.usersign}</p></div>
            {/if}
            <span style="float: right;">{:range_time($question.adopt.create_time)}</span>
          </div>
          <div class="wenda-adopt-content" style="margin-bottom: 15px;">{$question.adopt.content|raw}</div>
          {if $question.adopt_thank}<div><blockquote class="layui-elem-quote"><span class="layui-badge layui-bg-green">提问者评价</span> {$question.adopt_thank}</blockquote></div>{/if}
          <div class="wenda-adopt-handle" style="margin-bottom: 10px;">
              <a href="{:url('wendasns/answer/praise')}" class="layui-btn layui-btn-sm layui-btn-primary J_req" data-click="praise" data-json='{"id":"{$question.adopt.id}","type":"answer"}' style="margin-right: 10px;"><i class="layui-icon layui-icon-praise"></i><font>{$question.adopt.praise}</font></a>
              <a href="javascript:;" style="margin-right: 10px;" class="J_comment" data-json='{"id":"{$question.adopt.id}","type":"answer"}'><i class="layui-icon layui-icon-reply-fill"></i> 评论(<span id="comment-num-{$question.adopt.id}">{$question.adopt.comment}</span>)</a>
              {if miniapp() neq true}<a href="#share" style="margin-right: 10px;" class="J_req" data-click="share"><i class="layui-icon layui-icon-share"></i> 分享</a>{/if}
              <a href="{:url('wendasns/api/report')}" style="margin-right: 10px;" class="J_dialog" data-json='{"id":"{$question.adopt.id}","type":"answer"}' title="举报"><i class="layui-icon layui-icon-tips"></i> 举报</a>
          </div>
		<!--评论列表-->
		<div class="comment-row comment-card-{$question.adopt.id}" style="background: #fafafa;display: none;">
			<div class="comment-card-body" style="padding: 10px;">
		{~$comment = $question->adopt->comments()}
		<ul id="comment-answer-{$question.adopt.id}" class="answer-comment comment-card-list" style="margin-top: 10px;">
		{include file="unify/comment"}
		</ul>
		{if $comment->total()>0}<div class="comment-page pager">{$comment->render()|raw}</div>{/if}
			</div>
		</div>
		<!--评论列表 end-->
        </div>
        
      </div>
      {/if}
      <!--最佳答案 end-->

      {if $answer->total()>0}
      <div class="layui-card">
        <div class="layui-card-header">{$answer->total()}个回复</div>
        <div class="layui-card-body">
        	<div id="answer-list">
        		{include file="answer"}
          	</div>
        </div>
      </div>
      {/if}
      
      {:load_advert('QuestionPageAnswerBottom')}
      
      <div class="layui-card">
        <div class="layui-card-header">等待回复</div>
        <div class="layui-card-body">
          <ul>
          {volist name=":load_question('unanswer',10)" id="item"}
            <li style="margin-bottom: 5px;"><a href="{:url('wendasns/question/show',$item)}">{:substr_format($item.title)}</a><span style="float: right;">{:range_time($item.create_time)}</span></li>
          {/volist}
          </ul>
        </div>
      </div>
      
      
    </div>

    <div class="layui-col-md4">
    {if count($alike)}
      <div class="layui-card">
        <div class="layui-card-header">其他类似问题</div>
        <div class="layui-card-body">
          <ul>
          {volist name="alike" id="item"}
            <li style="margin-bottom: 5px;"><a href="{:url('wendasns/question/show',$item)}">{:substr_format($item.title)}</a><span style="float: right;">{:range_time($item.create_time)}</span></li>
          {/volist}
          </ul>
        </div>
      </div>
    {/if}
      {include file="common/right"}
    </div>
    
  </div>
</div>


<div id="layui-anim" style="background-color: #fff;position: fixed;top: 0;width: 100%;left: 0;z-index: 10001;border-bottom: 1px solid #dae0e4;box-shadow:0 2px 10px 0 rgba(0,0,0,.15);display: none;">
  <div class="layui-container">
    <div class="layui-row">
      <div class="layui-col-md8">
        <div class="layui-card" style="overflow: hidden;">
            <h2 style="color: #000000;height: 60px;line-height: 60px;">{$question.title}</h2>
        </div>
      </div>
      <div class="layui-col-md4">
        <div class="layui-card">
          <div class="layui-hide-xs" style="margin-top: 10px;text-align: center;">
            <div class="layui-col-md6 layui-col-sm6 layui-col-xs6"><p>收藏量</p><mdall>{$question.collect}</mdall></div>
            <div class="layui-col-md6 layui-col-sm6 layui-col-xs6"><p>浏览量</p><mdall>{$question.visits}</mdall></div>
            </div>
        </div>
      </div>
    </div>
  </div>
</div>

{include file="common/footer"}
<!--采纳-->
<script id="adopt_view" type="text/html">
<div class="layui-row" style="width: 500px;">
  <div class="layui-card">
    <div class="layui-card-body">
      <form class="layui-form" action="{:url('wendasns/question/adopt')}" method="post">
        <input type="hidden" name="id" value="{{d.id || ''}}"/>
        <input type="hidden" name="aid" value="{{d.aid || ''}}"/>
        <div class="layui-form-item"><input name="content" value="" placeholder="选填：评价一下这条回复吧！" class="layui-input"></div>
        <div class="layui-form-item">
          <div class="layui-inline" style="float: right;">
            <div class="layui-input-inline" style="width: auto;">
              <button class="layui-btn" lay-submit="" lay-filter="J_ajax_submit_btn">提交</button>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
</script>

<!--补充问题/回答-->
<script id="form_edit_view" type="text/html">
<div class="layui-card-body">
  <form id="editor-form-item" class="layui-form" action="{{d.action||''}}" method="post">
    <input type="hidden" name="id" value="{{d.id||''}}"/>
    <div class="layui-form-item"><textarea id="wd-textarea" name="content" lay-verify="content" class="layui-hide" data-id="">{{d.content||''}}</textarea></div>
    <div class="layui-form-item">
      <div class="layui-inline" style="text-align: right;float: right;margin-right: 0;">
        <div class="layui-input-inline" style="width: auto;margin-right: 0;">
          {if miniapp() neq true}<input type="checkbox" name="anonymous" lay-skin="primary" title="匿名" value="1">{/if}
          <button class="layui-btn" lay-submit="" lay-filter="J_ajax_submit_btn">提交</button>
        </div>
      </div>
    </div>
  </form>
</div>
</script>

<!--编辑回答-->
<script id="answer_edit_view" type="text/html">
<div class="layui-row" style="width: 500px;">
  <div class="layui-card">
    <div class="layui-card-body">
      <form class="layui-form" action="{:url('wendasns/answer/edit')}" method="post">
        <input type="hidden" name="id" value="{{d.id || ''}}"/>
        <div class="layui-form-item"><textarea id="answer-edit-textarea" name="content" lay-verify="content" class="layui-hide" data-id=""></textarea></div>
        <div class="layui-form-item">
          <div class="layui-inline" style="text-align: right;float: right;">
            <div class="layui-input-inline" style="width: auto;">
              <button class="layui-btn" lay-submit="" lay-filter="J_ajax_submit_btn">提交</button>
            </div>
          </div>
        </div>
    </form>
    </div>
  </div>
</div>
</script>

<!--评论发表-->
<script id="comment_post_view" type="text/html">
<div class="{{d.css||''}}">
<form action="{:url('wendasns/comment/post')}" class="layui-form" style="position: relative;">
	<input type="hidden" name="type" value="{{d.type}}"/>
	<input type="hidden" name="id" value="{{d.id}}"/>
	<div style="margin-right: 74px;"><input type="text" name="content" required="" lay-verify="required" placeholder="{{d.tips||''}}" autocomplete="off" class="layui-input"></div>
	<div style="position: absolute;top: 0;right: 0;"><button class="layui-btn" lay-submit lay-filter="J_ajaxReply">发表</button></div>
</form>
</div>
</script>

<script>
;!function(){
  var $ = layui.$
  ,form = layui.form
  ,flow = layui.flow
  ,laytpl = layui.laytpl
  ,layedit = layui.layedit;
  
  //页面滚动，显示顶部标题
  $(document).scroll(function(){
    var scroH = $(document).scrollTop();  //滚动高度
    if(scroH >190){
      $('#layui-anim').fadeIn('slow');
    }else{
      $('#layui-anim').fadeOut('slow');
    }
  });

  
  //加载回答
    flow.load({
      elem: '#answer-list'
      ,isAuto: false
      ,isLazyimg: true
      ,done: function(page, next){ //加载下一页
        if(page>1){
	        $.get('{:url('wendasns/question/answer')}',{id:wdinfo.id,page:page},function(res){
	        	next(res, page < {$answer->lastPage()});
	        });
        }else{
        	next('', page < {$answer->lastPage()});
        }
      }
    });
    
    //加载评论
	$('.comment-card-list').each(function(){
		var total = $(this).data('total'),id = $(this).data('id');
	    flow.load({
	      elem: '#'+$(this).prop('id')
	      ,isAuto: false
	      ,isLazyimg: true
	      ,done: function(page, next){ //加载下一页
	        if(page>1){
		        $.get('{:url('wendasns/comment/list')}',{id:id,page:page,type:'answer'},function(res){
		        	next(res, page < total);
		        });
	        }else{
	        	next('', page < total);
	        }
	      }
	    });
	});

    layui.code({
      elem: 'pre'
      ,about: false
    });
    
}();
</script>
</body>
</html>